package com.cooper.scraper.show;

import com.cooper.android.comm.GalleryFlow;
import com.cooper.android.comm.Resource;
import com.cooper.scraper.R;

import android.content.Context;
import android.view.Display;
import android.view.ViewGroup.LayoutParams;
import android.widget.Gallery;
import android.widget.RelativeLayout;

public class FlowGalleryViewFactory<T extends Resource> extends
		GalleryFanartShow<T> {

	public FlowGalleryViewFactory(Context context, Display display,
			FanartViewStrategy<T> fanartStrategy, FanartSizeStrategy fanartSize) {
		super(context, display, fanartStrategy, fanartSize);
	}

	@Override
	public Gallery getAdapterView(Context context, float fanartWidth,
			float fanartHeight) {
		GalleryFlow gallery = new GalleryFlow(context);
		gallery.setBackgroundResource(R.drawable.showcase);
		gallery.setFadingEdgeLength(0);

		RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
				LayoutParams.FILL_PARENT, (int) (fanartHeight + fanartHeight
						/ 3 * Math.abs(fanartHeight / gallery.getMaxZoom())));
		lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
		lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
		gallery.setLayoutParams(lp);
		return gallery;
	}

	@Override
	public void destroy() {
		super.destroy();
	}

	@Override
	protected FanartImgStrategy getFanartImgStrategy() {
		return LightFanartImgStragety.getInstance();
	}

}
